import tensorflow as tf
from tensorflow.keras import layers, models

# 构建生成模型
class Generator(models.Model):
    def __init__(self):
        super(Generator, self).__init__()
        self.dense1 = layers.Dense(128, activation='relu')
        self.dense2 = layers.Dense(784, activation='tanh')

    def call(self, x):
        x = self.dense1(x)
        return self.dense2(x)

# 示例代码
generator = Generator()
noise = tf.random.normal([1, 100])
generated_image = generator(noise)
print("Generated image shape:", generated_image.shape)